#include <linux/err.h>
#include <asm/uaccess.h>
#include <linux/interrupt.h>
#include <linux/input.h>
#include "ads7870-core.h"
#include "ads7870-spi.h"
#include <linux/spi/spi.h>
#include <plat/mcspi.h>

#define MAXLEN             512
#define MODULE_DEBUG 0

/* 
 * Pointer to SPI Device 
 */
static struct spi_device *ads7870_spi_device;

/* 
 * SPI Configuration Structure
 * Used when creating a new SPI Device
 */
static struct omap2_mcspi_device_config ads7870_mcspi_config = {
  .turbo_mode	        = 0,
  .single_channel	= 1,  /* 0: slave, 1: master */
};

struct spi_board_info omap3devkit8000_spi_board_info[] = {
  {
    .modalias		= "ads7870",
    .bus_num		= 4,
    .chip_select	= 0,
    .max_speed_hz	= 15000000,
    .controller_data	= &ads7870_mcspi_config,
    .mode               = SPI_MODE_3, // Clock polarity
  },

};
u16* ads7870_read(void)
{
  return ads7870_spi_read_reg16(ads7870_spi_device);
}

int ads7870_init(void) {
  return ads7870_spi_init(&ads7870_spi_device,  &omap3devkit8000_spi_board_info[0]);
}


int ads7870_exit(void) {
  return ads7870_spi_exit(ads7870_spi_device);
}
